package implementacionJ48;

import weka.core.Attribute;
import weka.core.Instance;
import java.util.*;

import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;

import weka.core.Instances;

public class SplitInfo {

	public static double calculateSplitInfo(Instances S, double[] Ti, int numeroAtributo) throws Exception{
	
		/* Aqui traemos la cant. total de filas */
		int cantFilasTotal = S.attributeStats(0).totalCount;
			
		Enumeration instancias = S.enumerateInstances();
		
		double info = 0.0;
		for(int i = 0; i < Ti.length; i++){
			double p = (double) Ti[i]/(double)cantFilasTotal;
			if(p != 0.0)
				info += p*(Math.log10(p)/Math.log10(2));
		}
			
		return -info;
		
	}
	
	/*public static double calculateGainRatio(Instances S, double[] Ti) throws Exception{
		
		
		
		return 0.0;
		
	}*/
	
	
}
